//
//  UIImage+Extension.swift
//  123
//
//  Created by pangjiaxing on 16/1/7.
//  Copyright © 2016年 pangjiaxing. All rights reserved.
//

import UIKit

extension UIImage{
    
    //截屏
    class func getScreenShot()->UIImage{
        let window = UIApplication.sharedApplication().keyWindow
        UIGraphicsBeginImageContextWithOptions((window?.frame.size)!, false, 0)
        window?.drawViewHierarchyInRect(CGRect(origin: CGPointZero, size: window!.frame.size), afterScreenUpdates: false)
        
        let image = UIGraphicsGetImageFromCurrentImageContext()
        // 4. 关闭上下文
        UIGraphicsEndImageContext()
        // 5. 返回
        return image
    }

}
